/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.model.master;

import javax.jdo.annotations.Column;
import javax.jdo.annotations.FetchGroup;
import javax.jdo.annotations.FetchGroups;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

/**
 *
 * @author kmcsoft02
 */
@PersistenceCapable(detachable = "true", table = "SHOP_Product")
@FetchGroups(value = {
    @FetchGroup(name = "detach_ProductDiamond_All", members = {
        @Persistent(name = "unit"),
        @Persistent(name = "currency"),
        @Persistent(name = "costCurrency"),
        @Persistent(name = "statusHistoryProducts"),
        @Persistent(name = "diamondGroup"),
        @Persistent(name = "diamondColor"),
        @Persistent(name = "diamondPure"),
        @Persistent(name = "importJewelryDetail")}),
    @FetchGroup(name = "detach_ProductDiamond_CreatedBy", members = {
        @Persistent(name = "createdBy")}),
    @FetchGroup(name = "detach_ProductDiamond_DiamondGroup", members = {
        @Persistent(name = "diamondGroup")}),
    @FetchGroup(name = "detach_ProductDiamond_DiamondColor", members = {
        @Persistent(name = "diamondColor")}),
    @FetchGroup(name = "detach_ProductDiamond_DiamondPure", members = {
        @Persistent(name = "diamondPure")})
})
public class ProductDiamond extends Product {

    @Persistent
    private DiamondGroup diamondGroup;
    @Persistent
    @Column(defaultValue = "0")
    private double nimro;
    @Persistent
    @Column(defaultValue = "0")
    private double size1;
    @Persistent
    @Column(defaultValue = "0")
    private double size2;
    @Persistent
    @Column(defaultValue = "0")
    private double size3;
    @Persistent
    @Column(defaultValue = "0")
    private double diamondWeight;
    @Persistent
    private DiamondColor diamondColor;
    @Persistent
    private DiamondPure diamondPure;
    @Persistent
    private ProductPremiumJewelry premiumJewelry;
    @Persistent
    private String madeFrom;

    public ProductPremiumJewelry getPremiumJewelry() {
        return premiumJewelry;
    }

    public void setPremiumJewelry(ProductPremiumJewelry premiumJewelry) {
        this.premiumJewelry = premiumJewelry;
    }

    
    public DiamondGroup getDiamondGroup() {
        return diamondGroup;
    }

    public void setDiamondGroup(DiamondGroup diamondGroup) {
        this.diamondGroup = diamondGroup;
    }

    public double getNimro() {
        return nimro;
    }

    public void setNimro(double nimro) {
        this.nimro = nimro;
    }

    public double getSize1() {
        return size1;
    }

    public void setSize1(double size1) {
        this.size1 = size1;
    }

    public double getSize2() {
        return size2;
    }

    public void setSize2(double size2) {
        this.size2 = size2;
    }

    public double getSize3() {
        return size3;
    }

    public void setSize3(double size3) {
        this.size3 = size3;
    }

    public double getDiamondWeight() {
        return diamondWeight;
    }

    public void setDiamondWeight(double diamondWeight) {
        this.diamondWeight = diamondWeight;
    }

    public DiamondColor getDiamondColor() {
        return diamondColor;
    }

    public void setDiamondColor(DiamondColor diamondColor) {
        this.diamondColor = diamondColor;
    }

    public DiamondPure getDiamondPure() {
        return diamondPure;
    }

    public void setDiamondPure(DiamondPure diamondPure) {
        this.diamondPure = diamondPure;
    }

    public String getMadeFrom() {
        return madeFrom;
    }

    public void setMadeFrom(String madeFrom) {
        this.madeFrom = madeFrom;
    }

    public double getPercentSize() {
        if (diamondGroup == null) {
            return 0;
        }
        if (diamondGroup.getSize() < 4) {
            return 0;
        }
        if ((size1 + size2) == 0) {
            return 0;
        }
        return (size3 * 2) / (size1 + size2);
    }
}
